libobs_simple\sources\linux\sources/
v4l2_input.rs1use libobs_wrapper::{data::StringEnum, sources::ObsSourceRef};
2use num_derive::{FromPrimitive, ToPrimitive};
3
4use crate::sources::macro_helper::{define_object_manager, impl_default_builder};
5
6#[repr(i64)]
7#[derive(Clone, Copy, Debug, PartialEq, Eq, FromPrimitive, ToPrimitive)]
8pub enum ObsV4L2ColorRange {
10 Default = 0,
12 Partial = 1,
14 Full = 2,
16}
17
18impl StringEnum for ObsV4L2ColorRange {
19 fn to_str(&self) -> &str {
20 match self {
21 ObsV4L2ColorRange::Default => "Default",
22 ObsV4L2ColorRange::Partial => "Partial",
23 ObsV4L2ColorRange::Full => "Full",
24 }
25 }
26}
27
28define_object_manager!(
29 #[derive(Debug)]
30 struct V4L2InputSource("v4l2_input", *mut libobs::obs_source) for ObsSourceRef {
35 #[obs_property(type_t = "string")]
37 device_id: String,
38
39 #[obs_property(type_t = "int")]
41 input: i64,
42
43 #[obs_property(type_t = "int")]
45 pixelformat: i64,
46
47 #[obs_property(type_t = "int")]
49 standard: i64,
50
51 #[obs_property(type_t = "int")]
53 dv_timing: i64,
54
55 #[obs_property(type_t = "int")]
56 resolution: i64,
57
58 #[obs_property(type_t = "int")]
59 framerate: i64,
60
61 #[obs_property(type_t = "int")]
63 color_range: i64,
64
65 #[obs_property(type_t = "bool")]
67 auto_reset: bool,
68
69 #[obs_property(type_t = "int")]
71 timeout_frames: i64,
72 }
73);
74
75impl V4L2InputSourceBuilder {
76 pub fn set_color_range_enum(self, color_range: ObsV4L2ColorRange) -> Self {
78 use num_traits::ToPrimitive;
79 self.set_color_range(color_range.to_i64().unwrap())
80 }
81}
82
83impl_default_builder!(V4L2InputSourceBuilder);